﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="btnslist.aspx.cs" Inherits="UI.system.page.menu.btnslist" %>
<%@ Import Namespace="Common" %>
<div style="margin: 25px;">
  <div class="layer-toolbar-left">
        <a class="layui-btn layui-btn-small" onclick="Save(0)">新&nbsp;增</a>
  </div>
  <table class="layui-table">
    <colgroup>
      <col width="120">
      <col>
      <col width="100">
      <col width="100">
      <col width="105">
    </colgroup>
    <thead>
      <tr>
        <th>名称</th>
        <th>方法</th>
        <th>颜色</th>
        <th>顺序</th>
        <th>操作</th>
      </tr>
    </thead>
     <tbody id="layer-table">
        <tr><td colspan="5" class="center">数据加载中...</td></tr>
    </tbody>
    <script id="data-table" type="text/html">
      {{#  layui.each(d, function(index, item){ }}
      <tr id="{{item.ID}}" address="{{item.Address}}" address2="{{item.Address2}}" class="cursor">
        <td>{{item.Name}}</td>
        <td>{{item.Method}}</td>
        <td>{{item.Color}}</td>
        <td><input class="layui-input tdtext" value="{{item.Sort}}" onblur="ReSort(this,{{item.ID}},'btns')" /></td>
        <td>
        <a class="layui-btn layui-btn-mini" onclick="Save({{item.ID}})">编辑</a>
        <a class="layui-btn layui-btn-mini layui-btn-danger" onclick="Delete(this,{{item.ID}})">删除</a>
        </td>
      </tr>
      {{#  }); }}
      </script>
  </table>
</div>
<script>
    function Save(id) {
        Ajax.Get("/system/page/menu/btnsadd.aspx?id=" + id, function (html) {
            var title = id == 0 ? "新增" : "修改";
            var index = window.parent.LayerBox.Show(title + "按钮", html, "590px", "440px", null, function (form) {
                var data = form;
                data.act = "Save_Btns";
                data.id = id;
                data.sign = GetSign(data.act);
                var load=LayerBox.Loading();
                Ajax.Post("/tools/Admin.ashx", data, function (r) {
                    var json = $.parseJSON(r);
                    if (json.state) {
                        LayerBox.Success(json.msg, 500, function () {
                            LayerBox.Close.ByIndex(load);
                            LayerBox.Close.ByIndex(index);
                            Init_Pager();
                        });
                    }
                    else {
                        LayerBox.Error(json.msg);
                    }
                });
            });
        });
    };

    function Delete(o, id) {
        LayerBox.Confirm("您确定要删除吗？", function () {
            Delete_Table(o, id, "Delete_Btns");
        });
    };

    function Init_Pager() {
            var data = {};
            data.act = "Find_Btns";
            data.sign = GetSign(data.act);
            Loading();
            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    Data(json.data.list);
                }
                else {
                    LayerBox.Error(json.msg);
                }
            });
        };
        Init_Pager();
</script>